package com.example.webdriveddd.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.Objects;

@Data
public class FileInfoDTO {
    private int id;
    private String fileName;
    private String fileType;
    private long fileSize;
    private int parentId;
    private int userId;
    private boolean shared;
    private String description;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime uploadTime;

    public boolean equals(Object other){
        if (other instanceof FileInfoDTO otherFile){
            if (this.id==otherFile.id){
                return true;
            }
            if (this.fileName.equals(otherFile.fileName)&&this.fileType.equals(otherFile.fileType)&&this.parentId==otherFile.parentId&&this.userId==otherFile.userId){
                return true;
            }
            return false;
        }
        return false;
    }

    @Override
    public int hashCode() {
        return Objects.hash(fileName, fileType, parentId, userId);
    }
}
